<?php
    /**
     * Created by PhpStorm.
     * User: huangzhongwei
     * Date: 2018/10/24
     * Time: 9:10
     */

    namespace app\common\model;


    use think\Model;

    class GoodsType extends Model
    {

        protected $table = "goods_type";
        protected $autoWriteTimestamp = true;




        public static function getAllGoodsTypeByUniversityId($id)
        {

            $result = self::where('university_id', $id)->with('goods')->order('create_time', 'desc')->select();
            return $result;
        }


        public function goods()
        {
            return $this->hasMany('Goods', 'goods_type_id');
        }


        public function university(){
            return $this->belongsTo('University','university_id');
        }
    }